package com.tarena.demo.luban.all.main.consumer;

import com.tarena.demo.luban.all.main.service.CartService;
import com.tarena.demo.luban.protocol.cart.param.CartDeleteParam;
import com.tarena.demo.luban.protocol.order.param.OrderAddParam;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic ="cart-delete-topic" ,consumerGroup = "${rocketmq.consumer.group}")
public class CartDeleteConsumer implements RocketMQListener<OrderAddParam> {
    @Autowired
    private CartService cartService;
    @Override
    public void onMessage(OrderAddParam message) {
        CartDeleteParam param=new CartDeleteParam();
        param.setProductCode(message.getProductCode());
        param.setUserId(message.getUserId());
        cartService.deleteCart(param);
    }
}
